<?php

namespace mpend\modules\ofc\models;

use Yii;

/**
 * 班组记工本按日期统计模型
 * 
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class MatchSearch extends \common\models\ofc\OfcMatch {

    /**
     * @inheritdoc
     */
    public function buildQuery($alias = 't') {
        $query = static::find();
        if ($alias) {
            $query->alias($alias);
            $alias .= '.';
        }
        $query->active(static::STATUS_ACTIVE);
        $query->innerJoinWith('season season');
        $query->andWhere([
            't.season_id' => $this->season_id,
        ]);
        $query->orderBy([
            $alias . 'match_time' => SORT_DESC,
        ]);
        $query->debug();
        return $query;
    }

    /**
     * @inheritdoc
     */
    public function fields() {
        return [
            'id',
            'title',
            'hostTeam',
            'guestTeam',
            'host_score',
            'guest_score',
            'matchTime',
            'venue',
            'location',
            'completed',
            'matchStatus',
        ];
    }

}
